/**
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
"use strict";
define(["ojs/ojcore","jquery","ojs/ojeditablevalue"],function(a,g){a.Ra("oj.inputBase",g.oj.editableValue,{version:"1.0.0",widgetEventPrefix:"oj",_ATTR_CHECK:[],_CLASS_NAMES:"",_WIDGET_CLASS_NAMES:"",_ELEMENT_TRIGGER_WRAPPER_CLASS_NAMES:"",_GET_INIT_OPTIONS_PROPS:[{ha:"disabled",Sd:!0},{ha:"pattern"},{ha:"placeholder"},{ha:"value"},{ha:"readonly",option:"readOnly",Sd:!0},{ha:"required",wh:!0,Sd:!0},{ha:"title"}],_INPUT_HELPER_KEY:"",D1:"blur",A2:"keydown",q2:"input",Y1:"drop",options:{converter:void 0,
placeholder:void 0,rawValue:void 0,readOnly:!1},dC:function(a){var c=this._superApply(arguments);this.yBa();return c},Yf:function(b,c){this._super(b,c);a.Fe.Cp(this._GET_INIT_OPTIONS_PROPS,c,this)},_ComponentCreate:function(){var a=this._superApply(arguments),c=this.options.readOnly;this.Pg="rtl"===this.nd();"boolean"===typeof c&&this.element.prop("readonly",c);this.UB()?(this.VFa(),this.Z1()&&this.ZQ(),this._focusable({element:this.bk,applyHighlight:!0})):this._focusable({element:this.element,applyHighlight:!0});
this.tS={};this.$e=null;return a},Nh:function(){var a=this._superApply(arguments),c=this;this._CLASS_NAMES&&this.element.addClass(this._CLASS_NAMES);this.v4();this.IP();g.each(["disabled","readOnly"],function(a,b){c.options[b]&&c.pba(b,c.options[b])});return a},pba:function(a,c){"disabled"===a&&this.element.prop("disabled",c);"readOnly"===a&&(this.element.prop("readonly",c),this.bL("readOnly",c));"disabled"!==a&&"readOnly"!==a||this.v4()},_setOption:function(b,c){var d=this._superApply(arguments);
"disabled"!==b&&"readOnly"!==b||this.pba(b,c);"pattern"===b&&(this.tS[a.Ve.VALIDATOR_TYPE_REGEXP]=this.b8(),this.Px());return d},_destroy:function(){var b=this._superApply(arguments);this.element.off("blur drop keydown input");this.aV&&this.aV.remove();this.UB()&&(this.Z1()?a.D.unwrap(this.element,this.bk):a.D.unwrap(this.element));return b},v4:function(){if(!this.options.readOnly&&!this.options.disabled){this.$e={};var a=g.proxy(this.LV,this),c=g.proxy(this.OK,this),d=g.proxy(this.SAa,this),e=function(){this.focus()};
this.element.on("blur",a);this.element.on("keydown",c);this.element.on("input",d);this.element.on("drop",e);this.$e[this.D1]=a;this.$e[this.A2]=c;this.$e[this.q2]=d;this.$e[this.Y1]=e}else if(this.$e)for(a=[this.D1,this.A2,this.q2,this.Y1],c=0,d=a.length;c<d;c++)this.$e[a[c]]&&(this.element.off(a[c],this.$e[a[c]]),delete this.$e[a[c]])},js:{readOnly:"oj-read-only"},yBa:function(){for(var a=this._ATTR_CHECK,c=0,d=a.length;c<d;c++){var e=a[c].attr;"setMandatory"in a[c]&&this.element.attr(e,a[c].setMandatory)}},
LV:function(a){this.wc(this.Si(),a)},OK:function(a){a.keyCode===g.ui.keyCode.ENTER&&this.wc(this.Si(),a)},SAa:function(a){this.jq(this.Xf().val(),a)},UB:function(){return this._WIDGET_CLASS_NAMES},Z1:function(){return this._ELEMENT_TRIGGER_WRAPPER_CLASS_NAMES},VFa:function(){this.oe?(this.bk=g(this.oe).addClass(this._WIDGET_CLASS_NAMES),this.bk.append(this.element)):(g(this.element).wrap(g("\x3cdiv\x3e").addClass(this._WIDGET_CLASS_NAMES)),this.bk=this.element.parent())},ZQ:function(){return g(this.element).wrap(g("\x3cdiv\x3e").addClass(this._ELEMENT_TRIGGER_WRAPPER_CLASS_NAMES)).parent()},
IP:function(){if(this._INPUT_HELPER_KEY&&this.UB()){var a=this.element.attr("aria-describedby")||"",c=this.Rm(this._INPUT_HELPER_KEY);this.element.attr("aria-describedby",a+(" "+c));this.aV=g("\x3cdiv class\x3d'oj-helper-hidden-accessible' id\x3d'"+c+"'\x3e"+this.Dj(this.F(this._INPUT_HELPER_KEY))+"\x3c/div\x3e");this.C1().append(this.aV)}},Dj:function(a){return g("\x3cspan\x3e"+a+"\x3c/span\x3e").text()},C1:function(){return this.widget()},WB:function(){var b=this._superApply(arguments);this.options.pattern&&
(this.tS[a.Ve.VALIDATOR_TYPE_REGEXP]=this.b8());return g.extend(this.tS,b)},bL:function(a,c){-1!=Object.keys(this.js).indexOf(a)&&this.widget().toggleClass(this.js[a],!!c)},b8:function(){if(!this.options.pattern)return null;var b={pattern:this.options.pattern,label:this.zT()};g.extend(b,this.options.translations.regexp||{});return a.za.sx(a.Ve.VALIDATOR_TYPE_REGEXP).createValidator(b)},Rm:function(a){return this.uuid+"_"+a},BMa:function(){return this.Pg},refresh:function(){var a=this._superApply(arguments);
this.Pg="rtl"===this.nd();return a},getNodeBySubId:function(a){return this._super(a)},widget:function(){return this.UB()?this.bk:this.element}},!0);a.Ra("oj.ojInputPassword",g.oj.inputBase,{version:"1.0.0",defaultElement:"\x3cinput\x3e",widgetEventPrefix:"oj",_ATTR_CHECK:[{attr:"type",setMandatory:"password"}],_CLASS_NAMES:"oj-inputpassword-input",_WIDGET_CLASS_NAMES:"oj-inputpassword oj-form-control oj-component",options:{pattern:""},getNodeBySubId:function(a){var c=this._superApply(arguments),d;
c||(d=a.subId,"oj-inputpassword-input"===d&&(c=this.element?this.element[0]:null));return c||null},_GetDefaultStyleClass:function(){return"oj-inputpassword"}});a.Ra("oj.ojTextArea",g.oj.inputBase,{version:"1.0.0",defaultElement:"\x3ctextarea\x3e",widgetEventPrefix:"oj",_ATTR_CHECK:[],_CLASS_NAMES:"oj-textarea-input",_WIDGET_CLASS_NAMES:"oj-textarea oj-form-control oj-component",options:{pattern:""},getNodeBySubId:function(a){var c=this._superApply(arguments),d;c||(d=a.subId,"oj-textarea-input"===
d&&(c=this.element?this.element[0]:null));return c||null},_GetDefaultStyleClass:function(){return"oj-textarea"},oH:function(){return"oj-inputBase"}});a.Ra("oj.ojInputText",g.oj.inputBase,{version:"1.0.0",defaultElement:"\x3cinput\x3e",widgetEventPrefix:"oj",_ATTR_CHECK:[{attr:"type",setMandatory:"text"}],_CLASS_NAMES:"oj-inputtext-input",_WIDGET_CLASS_NAMES:"oj-inputtext oj-form-control oj-component",options:{pattern:""},getNodeBySubId:function(a){var c=this._superApply(arguments),d;c||(d=a.subId,
"oj-inputtext-input"===d&&(c=this.element?this.element[0]:null));return c||null},_GetDefaultStyleClass:function(){return"oj-inputtext"},oH:function(){return"oj-inputBase"}});a.Components.Xa("inputBase","editableValue",{properties:{converter:{type:"Object"},placeholder:{type:"string"},rawValue:{type:"string",readOnly:!0,writeback:!0},readOnly:{type:"boolean"}},methods:{refresh:{},widget:{}},extension:{_hasWrapper:!0,_innerElement:"input",_widgetName:"inputBase"}});a.Components.Xa("ojInputPassword",
"inputBase",{properties:{pattern:{type:"string"},value:{type:"string",writeback:!0}},methods:{},extension:{_hasWrapper:!0,_innerElement:"input",_widgetName:"ojInputPassword"}});a.Components.register("oj-input-password",a.Components.getMetadata("ojInputPassword"));a.Components.Xa("ojInputText","inputBase",{properties:{pattern:{type:"string"},value:{type:"string",writeback:!0}},methods:{},extension:{_hasWrapper:!0,_innerElement:"input",_widgetName:"ojInputText"}});a.Components.register("oj-input-text",
a.Components.getMetadata("ojInputText"));a.Components.Xa("ojTextArea","inputBase",{properties:{pattern:{type:"string"},value:{type:"string",writeback:!0}},methods:{},extension:{_hasWrapper:!0,_innerElement:"textarea",_widgetName:"ojTextArea"}});a.Components.register("oj-text-area",a.Components.getMetadata("ojTextArea"))});